<link href="admin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<{$config.weburl}>/script/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="<{$config.weburl}>/script/jquery.ui.js"></script>
<div class="container">
<div class="oflow" style="height:545px">
<form name="form1" id="form1" action="module.php?m=product&s=order_opear.php" method="post">
<input name="id" type="hidden" id="id" value="<{$de.order_id}>">
<input type="hidden" name="money" value="<{$de.cost}>" />
<input type="hidden" name="is_before_pay" value="1" />
<table class="table">
    <thead>
        <tr>
            <th class="partition" colspan="99">订单详情</th>
        </tr>
    </thead>
    <tbody>
    <tr class="tr">
        <td width="50">订单状态</td>
        <td width="100"><b class="org"><{$de.statu_text}></b></td>
    
        <td width="50">订单编号</td>
        <td width="150"><{$de.order_id}></td>
        
        <td width="50">下单时间</td>
        <td width="150"><{$de.create_time|date_format:"%Y-%m-%d&nbsp;%H:%M:%S"}></td>
    </tr>
    <tr class="tr">
        <td>支付状态</td>
        <td><{$de.order_ship_status}></td>
		
        <td>配送状态</td>
        <td width="100"><{$de.order_pay_status}></td>
		
		<td width="50">下单平台</td>
		<td width="50"><{$client_platform[$de.client_platform]}></td>
		
		<td width="50">操作系统</td>
		<td><{$client_system[$de.client_system]}></td>
    </tr>
    </tbody>
</table>
<table class="table product">    
    <thead>
        <tr>
            <th class="partition" colspan="99">订单信息</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td class="al">编号</td>
			<td width="100">产品ID</td>
			<td width="60">产品图</td>
            <td class="al">产品</td>
            <td width="90">单价</td>
            <td width="90">数量</td>
            <td width="90">总价</td>
        </tr>
        <{foreach item=list from=$de.product}>
        <tr>
            <td class="al"><{$list.code}></td>
			<td><{$list.pid}></td>
			<td width="50"><a href="<{$list.pic}>" target="_blank"><img width="50" height="50" src="<{$list.pic}>" onmouseover="javascript:showOriginImg('<{$list.pic}>');" onmouseout="javascript:hideOriginImg();"/></a></td>
            <td class="al <{if $list.service}>npb<{/if}>">
                <a target="_blank" href="http://www.haioo.com/item-<{$list.pid}>.html">
                    <{$list.name}>
                </a>
            </td>
            <td <{if $list.service}>class="npb"<{/if}>><input type='text' style="width: 100px;" name="sku_price[<{$list.id}>]" id="sku_price_<{$list.id}>" onblur="change_price('<{$list.id}>');" value='<{$list.price|number_format:2}>' /></td>
            <td <{if $list.service}>rowspan="2"<{/if}>><span id="sku_num_<{$list.id}>" num="<{$list.num}>"><{$list.num}></span></td>
            <td <{if $list.service}>rowspan="2"<{/if}>><{$config.money}><span class="sku_sum" id="sku_sum_<{$list.id}>" sum_price="<{$list.sum|number_format:2}>"><{$list.sum|number_format:2}></span></td>
        </tr>
        <{if $list.product_give}>
        <tr class="product_give">
            <td class="al">赠品</td>
            <td class="al">
                <{foreach item=slist from=$list.product_give}>
                    <li><{$slist.pname}></li>
                <{/foreach}>
            </td>
        </tr>
        <{/if}>
        <{if $list.service}>
        <tr class="other">
            <td class="al">服务</td>
            <td class="al">
                <{foreach item=slist from=$list.service}>
                    <li><{$slist.name}></li>
                <{/foreach}>
            </td>
            <td>
                <{foreach item=slist from=$list.service}>
                    <p><{$config.money}><{$slist.price}></p>
                <{/foreach}>
            </td>
        </tr>
        <{/if}>
        <{/foreach}>
        <{if $de.des}>
        <tr>
            <td class="al" colspan="99">备注: <{$de.des}></td>
        </tr>
        <{/if}>
    </tbody>
	<div id="productImgDetail" align="center" style="position:fixed;top:19%;left:14%;display:none;"><img width="240" height="240" src="" onerror="this.src='../image/admin/sns_img_fail_min.jpg'" /></div>
</table>
<table class="table">
    <tbody>
    <{if $de.status==1 and $de.pay_status==1}>
    <tr>
        <td width="100">商品总金额:</td>
        <td width="200">
        <input type="text" name="cost" id="cost" readonly value="<{$de.cost}>" />
        </td>
        <td width="100">配送方式：</td>
        <td>
            <select name="shipping_id" class="w162">
            <{foreach item=list from=$ship}>
                <option <{if $de.shipping_id==$list.id}>selected="selected"<{/if}> value="<{$list.id}>"><{$list.title}></option>
            <{/foreach}>
            </select>
        </td>
    </tr>
    <tr>
        <td>配送费用:</td>
        <td><input type="text" onblur="count()" id="freight" name="freight" value="<{$de.freight}>" /></td>
        <td>支付方式：</td>
        <td>
        <select name="payment_id" class="w162">
        <{foreach item=list from=$pay}>
            <option <{if $de.payment_id==$list.payment_id}>selected="selected"<{/if}> value="<{$list.payment_id}>"><{$list.payment_name}></option>
        <{/foreach}>
        </select>
        </td>
    </tr>
    <tr>
        <td>商品重量:</td>
        <td><input type="text" name="weight" value="<{$de.weight}>" /></td>
<!--         <td>订单折扣或涨价：</td>
        <td>
        <input type="text" onblur="count()" name="rebate" id="rebate" value="" class="w160" oninput="javascript:inputBuynum(this);" />
        <span class="hint">输入"-100","100"</span>
        </td> -->
        <td>余额支付:</td>
        <td><input type="text" name="cash_price" id="cash_price" readonly value="<{$de.cash_price|number_format:2}>" /></td>    	
    </tr>
    <tr>
		<td>活动优惠:</td>
		<td><input type="text" name="discount" id="discount" readonly value="<{$de.discount|number_format:2}>" /></td>
        <td>优惠券:</td>
        <td><input type="text" name="cpns_price" id="cpns_price" readonly value="<{$de.cpns_price|number_format:2}>" /></td>
    </tr>
    <tr>
        <td>行邮税:</td>
        <td><input type="text" onblur="count()" name="tax_price" id="tax_price" value="<{$de.tax_price}>"></td>
        <td>保险费:</td>
        <td><input type="text" onblur="count()" name="insurance_fee" id="insurance_fee" value="<{$de.insurance_fee}>"></td>
    </tr>
    <tr>
        <td>应付总额:</td>
        <td colspan='3'><input type="text" name="price" id="price" disabled="disabled" value="<{$de.cost+$de.freight+$de.tax_price+$de.insurance_fee-$de.cash_price-$de.cpns_price-$de.discount|number_format:2}>" /></td>
    </tr>
	<{else}>
    <tr>
        <td width="100">商品总金额:</td>
        <td width="200"><{$config.money}><{$de.cost}></td>
        <td width="100">配送方式：</td>
        <td><{$de.shipping_name}></td>
    </tr>
    <tr>
        <td>配送费用:</td>
        <td><{$config.money}><{$de.freight}></td>
        <td>支付方式：</td>
        <td><{$de.payment_name}></td>
    </tr>
    <tr>
        <td>商品重量:</td>
        <td><{$de.weight}>kg</td>
        <td>余额支付:</td>
        <td>-<{$config.money}><{$de.cash_price}></td>    
    </tr>
    <tr>
        <td>优惠券:</td>
        <td>-<{$config.money}><{$de.cpns_price}></td>    
        <td>活动优惠:</td>
        <td>-<{$config.money}><{$de.discount}></td>
    </tr>    
    <tr>
        <td>行邮税:</td>
        <td><{$config.money}><{$de.tax_price}></td>
        <td>保险费:</td>
        <td><{$config.money}><{$de.insurance_fee}></td>        
    </tr>
    <tr>
        <td>应付总额:</td>
        <td colspan='3'><{$config.money}><{$de.cost+$de.freight+$de.tax_price+$de.insurance_fee-$de.cash_price-$de.cpns_price-$de.discount}></td>
    </tr>
    <{/if}>
    </tbody>
</table>
<div style="margin:20px auto;"></div>
<div class="dialog_button">
<input id="save" type="button" value="保存">
<input name="act" type="hidden" id="action" value="edit">   
</div>
<div id="error"></div> 
<script>
//展示产品图片原图
function showOriginImg(src){
    var productImgDetail = $("#productImgDetail");
    productImgDetail.find('img').attr('src',src+"/560"); 
    productImgDetail.show();
}
//隐藏产品图片原图
function hideOriginImg(){
    $("#productImgDetail").hide();
}
function change_price(skuid)
{
	if(skuid>0)
	{
		var sku_price = $('#sku_price_'+skuid).val();
		if(sku_price<=0){
			alert('商品单价必须大于0');return false;
		}
		var sku_num = $('#sku_num_'+skuid).attr('num');
		var sku_sum = $('#sku_sum_'+skuid);
		var sum = sku_price*sku_num;
		sku_sum.attr('sum_price',sum);
		sku_sum.html(sum);
		
		var cost = 0;
		var all_sum = $('.sku_sum');
		all_sum.each(function(){
			var sum_price = -$(this).attr('sum_price');
			cost -= sum_price;
		});
		if(cost>0){
			$('#cost').val(Number(cost).toFixed(2));
			count();
		}
	}
}
function count()
{
	var cost=Number($("#cost").val()).toFixed(2);
	var freight=0-Number($("#freight").val()).toFixed(2);
	var cpns_price = Number($("#cpns_price").val()).toFixed(2);
	var discount = Number($("#discount").val()).toFixed(2);
	var cash_price = Number($("#cash_price").val()).toFixed(2);
	var tax_price = 0-Number($("#tax_price").val()).toFixed(2);
	var insurance_fee = 0-Number($("#insurance_fee").val()).toFixed(2);
	var rebate=Number($("#rebate").val()).toFixed(2);
	var price=cost-freight-tax_price-insurance_fee-cpns_price-discount-cash_price;
	$("#price").val(price);
}
function inputBuynum(ele){
	var buyNum = $(ele).val();
	var num = $("#price").val()*-1;
	if(buyNum!=null&&buyNum!=""){
		if(Number(buyNum)<Number(num)){
			alert("输入的数量有误");
			$(ele).val('0');
			count();
		}
	}
} 
function $$(id) {
	return !id ? null : document.getElementById(id);
}
function ajaxpost(formid) {
	var ajaxframeid = 'ajaxframe';
	var ajaxframe = $$(ajaxframeid);
	if(!ajaxframe){
		var div = document.createElement('div');
		div.style.display = 'none';
		div.innerHTML = '<iframe name="' + ajaxframeid + '" id="' + ajaxframeid + '" loading="1"></iframe>';
		ajaxframe = $$(ajaxframeid);
		$$('append_parent').appendChild(div);
	}
	$$(formid).target = ajaxframeid;
	$$(formid).submit();
	window.parent.main.document.location.reload();
	DialogManager.close("order");
}
$("#save").click(function () {
	if($("#price").val()<=0){
		alert('应付总额必须大于0');return false;
	}
	ajaxpost("form1");
	return false;
});
</script>
</form>
</div>
</div>